<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<script>
window.onload=function(){
	function getClass(classname,oParent){
		var oParent=oParent||document;
		var arr=[];
		if(document.getElementsByClassName){
			return document.getElementsByClassName(classname)	
		}else{
			var alls=document.getElementsByTagName('*');
			for(var i=0;i<alls.length;i++){
				if(checkclass(alls[i].className,classname)){
					arr.push(alls[i]);	
				};	
			};
			return arr;
		};	
	};
	
	function checkclass(moreclass,val){
		var arr=moreclass.split(' ');
		for(var i=0;i<arr.length;i++){
			if(arr[i]==val){
				return true;	
			};	
		};	
		return false;
	}
	alert(getClass('two').length)
	
}
</script>

<div id="one" class="one two">fd
	<span></span>
	<span></span>
	<span></span>
	<span></span>
</div>
<div id="one" class="one two">fd
</div>
<div id="one" class="one">fd
</div>
<div id="one" class="one">fd
</div>
</body>
</html>
